package com.example.sale.Service.imply;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sale.Mapper.FeedbackMapper;
import com.example.sale.Service.IFeedbackService;
import com.example.sale.True.Feedback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class FeedbackService  extends ServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {
    @Autowired
    FeedbackMapper feedbackMapper;
    @Override
    public IPage<Feedback> searchFeedback(Page<Feedback> page, Map<String, Object> params) {
        QueryWrapper<Feedback> wrapper = new QueryWrapper<>();
        // 根据传入的params参数，构造查询条件
        if (params.containsKey("time")) {
            String time = (String) params.get("time");
            wrapper.like("time", time);
        }
        if (params.containsKey("title")) {
            String title = (String) params.get("title");
            wrapper.eq("title", title);
        }
        if (params.containsKey("author")) {
            String author= (String) params.get("author");
            wrapper.eq("author", author);
        }
        return baseMapper.selectPage(page,wrapper);
    }
    @Override
    public Feedback getFeedbackById(Integer id) {
        Feedback feedback =feedbackMapper.getFeedbackById(id);
        System.out.println(feedback);
        return feedback;
    }
    @Override
    public boolean removeFeedbackById(Integer id) {
        Boolean flag =feedbackMapper.removeFeedbackById(id);
        return flag;
    }

    @Override
    public boolean isFeedBackExists(Integer id) {
        Feedback feedback =feedbackMapper.getFeedbackById(id);
        return feedback != null;
    }

    @Override
    public Integer FeedbackNumber(String number) {
          Integer ResolvedNumber = feedbackMapper.ResolvedNumber(number);
          return  ResolvedNumber;
    }
}
